#include "functors/MaxwellianFunctor.hpp"
#include <math.h>

MaxwellianFunctor::MaxwellianFunctor() {
}

MaxwellianFunctor::~MaxwellianFunctor() {
}

MaxwellianFunctor::MaxwellianFunctor(const MaxwellianFunctor &func) {
	vth=func.vth;
	vd=func.vd;
	vthsq=func.vthsq;
	prefac=func.prefac;
}

MaxwellianFunctor::MaxwellianFunctor(double _vth, double _vd) {
	vth=_vth;
	vd=_vd;
	vthsq=vth*vth;
	prefac=2./sqrt(M_PI)/vth;
}

double MaxwellianFunctor::operator() (double x) {
	return prefac*exp(-(x-vd)*(x-vd)/vthsq);
}

double MaxwellianFunctor::integrate(double a, double b) {
	return erf((vd-a)/vth)-erf((vd-b)/vth);	// negative signs on erf switch order of a (lower limit) and b (upper limit) terms
}